// 该文件专门用于创建整个应用的路由器
import VueRouter from "vue-router";
//引入组件
import Echarts from "../pages/Echarts";
import Home from "../pages/Home.vue";
import Info from "../pages/Person/Info.vue";
import Records from "../pages/Person/Records.vue";
import Feedback from "../pages/Help/Feedback.vue";
import Playback from "../pages/Playback.vue";
import Login from "../pages/User/Login.vue";
import Register from "../pages/User/Register.vue";

//创建并暴露一个路由器
const router = new VueRouter({
  routes: [
    {
      name: "echarts",
      path: "/echarts",
      component: Echarts,
      meta: { title: "数据对比" },
    },
    {
      name: "home",
      path: "/home",
      component: Home,
      meta: { title: "主页" },
    },
    {
      name: "info",
      path: "/info",
      component: Info,
      meta: { title: "个人信息" },
    },
    {
      name: "records",
      path: "/records",
      component: Records,
      meta: { title: "模拟记录" },
    },
    {
      name: "feedback",
      path: "/feedback",
      component: Feedback,
      meta: { title: "用户反馈" },
    },
    {
      name: "playback",
      path: "/playback",
      component: Playback,
      meta: { title: "回放" },
    },
    {
      name: "login",
      path: "/login",
      component: Login,
      meta: { title: "登录" },
    },
    {
      name: "register",
      path: "/register",
      component: Register,
      meta: { title: "注册" },
    },
  ],
});

// 后置路由守卫，这里用来：实现页签切换
router.afterEach((to) => {
  document.title = to.meta.title || "主页";
});

export default router;
